package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.service.BillService;
import com.zzyl.vo.BillVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.zzyl.base.ResponseResult.success;

@RestController
@RequestMapping("/bill")
@Api(tags = "账单管理")
public class BillController {

    @Autowired
    private BillService billService;

    @GetMapping("/page")
    @ApiOperation("分页查询")
    public ResponseResult<PageResponse<BillVo>> list(@ApiParam(value = "护理计划名称", required = false) String name,
                                                     @ApiParam(value = "当前页码", defaultValue = "1") Integer pageNum,
                                                     @ApiParam(value = "当前页码", defaultValue = "10") Integer pageSize,
                                                     @ApiParam(value = "状态", required = false) Integer transactionStatus){
        PageResponse<BillVo> response = billService.list(name,transactionStatus,pageNum,pageSize);
        return success(response);
    }

    @GetMapping("/{id}")
    @ApiOperation("根据id查询")
    public ResponseResult<BillVo> findById(Long id){
       BillVo billVo =  billService.findByID(id);
       return success(billVo);
    }
}
